<?php
namespace core;

use core\lib\log;
class Core
{
    public static $classMap = array();

    public static function run(){
        log::init();
        $route = new \core\lib\route();
        $control = ucfirst($route->control);
        $action = $route->action;
        $control_file = APP.'/controller/'.$control.'Controller.php';
        if(is_file($control_file)){
            C($control,$action);
            log::log('CONTROL:'.$control.'  ACTION:'.$action);
        }else{
            throw new \Exception('找不到对应控制器'.$control);
        }
    }

    /**
     *自动加载类库
     * $class='\core\routh'   自动引入的类
     * 需求   KJ.'/core/routh.php'
     */
    public static function load($class){
        if (isset(self::$classMap[$class])){
            return true;
        }else{
            $class = str_replace('\\','/',$class);
            $file = KJ.'/'.$class.'.php';
            if(is_file($file)){
                include $file;
                self::$classMap[$class] = true;
            }else{
                return false;
            }
        }
    }
}